package Events.gui;

import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import Events.StartGameEvent;

public class SetupPassengersTemp extends JPanel implements MouseListener{
	
	private static final long serialVersionUID = 1L;
	private StartGameEvent sge;
	private JTextField txtP1, txtP2, txtP3, txtP4;
	private JLabel lblP1, lblP2, lblP3, lblP4;
	private JButton btnNext;//, btnPrev;
	
	public SetupPassengersTemp(StartGameEvent sge){
		super();
		setLayout(null);
		this.setPreferredSize(new Dimension(600,500));
		
		this.sge = sge;
		
		lblP1 = new JLabel("Passenger 1:");
		lblP1.setHorizontalAlignment(SwingConstants.RIGHT);
		lblP1.setBounds(83, 71, 89, 14);
		add(lblP1);
		
		txtP1 = new JTextField(10);
		txtP1.setBounds(179, 68, 226, 20);
		add(txtP1);
		
		lblP2 = new JLabel("Passenger 2:");
		lblP2.setHorizontalAlignment(SwingConstants.RIGHT);
		lblP2.setBounds(83, 111, 89, 14);
		add(lblP2);
		
		txtP2 = new JTextField(10);
		txtP2.setBounds(179, 108, 226, 20);
		add(txtP2);
		
		lblP3 = new JLabel("Passenger 3:");
		lblP3.setHorizontalAlignment(SwingConstants.RIGHT);
		lblP3.setBounds(83, 154, 89, 14);
		add(lblP3);
		
		txtP3 = new JTextField(10);
		txtP3.setBounds(179, 151, 226, 20);
		add(txtP3);
		
		lblP4 = new JLabel("Passenger 4:");
		lblP4.setHorizontalAlignment(SwingConstants.RIGHT);
		lblP4.setBounds(83, 194, 89, 14);
		add(lblP4);
		
		txtP4 = new JTextField(10);
		txtP4.setBounds(179, 191, 226, 20);
		add(txtP4);
		
		btnNext = new JButton("Next");
		btnNext.setBounds(172, 282, 89, 23);
		btnNext.addMouseListener(this);
		add(btnNext);
		
		//TODO: Add functionality for going back to redo something
		//		Maybe not add anything to spaceship till after you complete 
		//		your party and are in the shop?
		//btnPrev = new JButton("Prev");
		//btnPrev.setBounds(285, 282, 89, 23);
		//btnPrev.addMouseListener(this);
		//add(btnPrev);
	}
	

	@Override
	public void mouseClicked(MouseEvent e) {
		if(e.getSource() == btnNext){
			if(!txtP1.getText().equals("") && 
					!txtP2.getText().equals("") && 
					!txtP3.getText().equals("") && 
					!txtP4.getText().equals("") )  {
				String[] party = {txtP1.getText(), txtP2.getText(), txtP3.getText(), txtP4.getText()};
				sge.createParty(party);
			}
		}
		//else if(e.getSource() == btnPrev){
		//	sge.prevPhase();
		//}
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {}

	@Override
	public void mouseExited(MouseEvent e) {}

	@Override
	public void mousePressed(MouseEvent e) {}

	@Override
	public void mouseReleased(MouseEvent e) {}
	
	
}
